package com.itheima.d1_collection_set;

import com.itheima.d1_collection_set.bean.Student;

import java.util.HashSet;
import java.util.Iterator;

/**
 * 目标：自定义的类型的对象，比如两个内容一样的学生对象，如果让HashSet集合能够去重复！
 */
public class SetTest3 {
    public static void main(String[] args) {

        HashSet<Student> hash = new HashSet<>();
        hash.add(new Student("小兮",18,170));
        hash.add(new Student("小兮",18,170));
        hash.add(new Student("小兮",18,160));

        for (Student student : hash) {
            System.out.println(student);
        }

        hash.forEach(s-> System.out.println(s));

        Iterator<Student> iterator = hash.iterator();
        while (iterator.hasNext()) {
            Student next = iterator.next();
            System.out.println( next);
        }

    }
}
